package com.xx.bysj.controller;

import com.xx.bysj.BysjApplication;
import com.xx.bysj.utils.NumberUtils;
import com.xx.bysj.utils.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletRequest;

@RestControllerAdvice
public class ExceptionController {

    private static final Logger logger = LoggerFactory.getLogger(BysjApplication.class);

    // 统一异常类返回
    @ExceptionHandler(Exception.class)
    public Result handleException(Exception e, HttpServletRequest request){
        logger.error("Request URL : {}, Exception : {}",request.getRequestURL(),e);
        return Result.fail(e.getMessage());
    }
}
